class ProductA {  
    use() {  
      return 'Product A';  
    }  
  }  
    
  class ProductB {  
    use() {  
      return 'Product B';  
    }  
  }  
    
  class ProductFactory {  
    static createProduct(type) {  
      if (type === 'A') {  
        return new ProductA();  
      } else if (type === 'B') {  
        return new ProductB();  
      }  
      return null;  
    }  
  }  
    
  const productA = ProductFactory.createProduct('A');  
  const productB = ProductFactory.createProduct('B');  
    
  console.log(productA.use()); // 输出 "Product A"  
  console.log(productB.use()); // 输出 "Product B"